package social.network.graph;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import shared.data.SharedData;

@SuppressWarnings("serial")
public class LimiteMaximo extends JApplet {

	private final JFrame frame;
	
	public LimiteMaximo(Collection<String> listVertex, final String caminhoArquivo){
		JLabel labelFrom = new JLabel();
		labelFrom.setText("De:");
		
		//final JTextField textFrom = new JTextField(20);
		@SuppressWarnings({ "rawtypes", "unchecked" })
		final JComboBox cboFrom = new JComboBox(listVertex.toArray());
		
		JLabel labelLimit = new JLabel();
		labelLimit.setText("Limite:");
		
		
		Object[] listLimit = {1,2,3,4,5};
		@SuppressWarnings({ "rawtypes", "unchecked" })
		final JComboBox cboLimit = new JComboBox(listLimit);
		
		JButton btnProcurar = new JButton();
		btnProcurar.setText("Procurar");
		btnProcurar.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent act) {
				
				SharedData.setVertexSel((String)cboFrom.getSelectedItem());
				SharedData.setLimite((Integer)cboLimit.getSelectedItem());
				GraphSIS graph = new GraphSIS(caminhoArquivo);
				graph.ListarQuantidadePorDistancia();
				frame.dispose();
				
				
			}
			
		});
		
		JPanel controls = new JPanel();
		controls.add(labelFrom);
		controls.add(cboFrom);
		controls.add(labelLimit);
		controls.add(cboLimit);
		controls.add(btnProcurar);
		controls.setSize(new Dimension(300,300));
		
		Container content = getContentPane();
		content.add(controls, BorderLayout.CENTER);
		
		frame = new JFrame();
		frame.setMinimumSize(new Dimension(300,150));
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.getContentPane().add(content);
        frame.pack();
        frame.setVisible(true);
	}
}
